package com.yunxiao.cloud.sharding.util;

/**
 * @description: HashUtil
 * @author: yunxiao
 * @date: 2020/1/2 10:18
 * @version: V1.0
 **/
public class HashUtil {
    private HashUtil() {
        // to do nothing
    }

    public static int rsHash(String value) {
        int one = 378551;
        int two = 63689;
        int hash = 0;
        for (int i = 0; i < value.length(); i++) {
            hash = hash * two + value.charAt(i);
            two = two * one;
        }
        return (hash & 0x7FFFFFFF);
    }
}
